#!/bin/bash

# project name.
PROJECT_NAME=stevejrong-blog-eureka

# branch name by project.
BRANCH_NAME=develop-1.0.0

# production of server
SERVER_ACCOUNT=root
SERVER_IP=104.168.173.43

# docker
DOCKER_ENTRYPORT=9000

echo ==================================================
echo Script startup for publishing $PROJECT_NAME
echo ==================================================

echo -e "-------------------- ready go!\n"

# execute docker command for pull and run
echo -e " ------------------- running docker container by image"
execCommands="sudo docker login; sudo docker pull $PROJECT_NAME:$BRANCH_NAME; sudo docker run --name $PROJECT_NAME-main -p $DOCKER_ENTRYPORT:$DOCKER_ENTRYPORT -d $PROJECT_NAME:$BRANCH_NAME"
echo Enter $SERVER_IP login password:
ssh $SERVER_ACCOUNT@$SERVER_IP "$execCommands"
echo -e " ------------------- run success.\n"

echo =================================================
echo Publish $PROJECT_NAME version $BRANCH_NAME completed!
echo =================================================